package util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DB_Connection {

	public static Connection getConnection() throws SQLException {

		Credentials cred = getCredentials();
		Connection connection = DriverManager.getConnection(
				"jdbc:mysql://localhost/bizdata", cred.getUsername(),
				cred.getPassword());

		return connection;
	}

	private static Credentials getCredentials() {

		/*
		 * Open configurations file (which is hidden) with FileReader and read
		 * the credentials to the class Credentials
		 */
		return new Credentials("sql_admin", "sqlp@ss123");
	}

}

class Credentials {
	private String username;
	private String password;

	public Credentials(String the_username, String the_password) {

		username = the_username;
		password = the_password;
	}

	public String getPassword() {
		return password;
	}

	public String getUsername() {
		return username;
	}
}